const fs = require('fs')
const path = require('path')
const f_path = path.join(__dirname, '../survey-data/manage-all-surveys.json')

function get() {
    try {
        const data = fs.readFileSync(f_path, 'utf8')
        return JSON.parse(data)
    } catch (error) {
        throw error
    }
}

function set(surveys) {
    try {
        fs.writeFileSync(f_path, JSON.stringify(surveys))
        return
    } catch (error) {
        throw error
    }
}

module.exports = {
    get,
    set,
}
